/*
 * @Author: jiu yin
 * @Date: 2023-04-04 13:37:46
 * @LastEditTime: 2023-04-24 13:48:23
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \admin\src\stores\app_process.js
 * jiu
 */
import { ref, computed, reactive, watchEffect } from 'vue'
import {getSession,setSession} from "@/utils"

import { defineStore } from 'pinia'


export const useApp_processStore = defineStore('app_process', () => {
    const list = reactive(getSession('app_process')||[])

    const mapList = computed(() => list )
    
    watchEffect(()=>{ 
        setSession('app_process',mapList.value)
    })

    function add(item) {
        let findIndex = list.findIndex((v) => v.path == item.path)
        if (findIndex != -1) return
        list.push(item)
    }
    function remove(index) {
        list.splice(index, 1)
    }

    return { list, mapList, add, remove }
})
